<?php

class AdminMenuEnum extends MenuEnum
{
    private static $UdoLeftMenu = array();

    private static $UdoUserMenus = array(
        'Account'                                       => array(
            self::TYPE   => self::MENU_TYPE_LEFT,
            self::PARENT => 0,                          //顶级模块
            self::LABEL  => 'account',
            self::TITLE  => '员工管理',
            self::URL    => '/account/teacherList'
        ),
        'Classes'                                       => array(
            self::TYPE   => self::MENU_TYPE_LEFT,
            self::PARENT => 0,
            self::LABEL  => 'classes',
            self::TITLE  => '班级管理',
            self::URL    => '/classes/classesList',
        ),
        'Permission'                                    => array(
            self::TYPE  => self::MENU_TYPE_LEFT,
            self::PARENT => 0,
            self::LABEL => 'permission',
            self::TITLE  => '权限分配表',
            self::URL   => '/permission/permissionTable',
        ),
        'Exercise'                                      => array(
            self::TYPE => self::MENU_TYPE_LEFT,
            self::PARENT => 0,
            self::LABEL  => 'classes',
            self::TITLE  => '题库管理',
            self::URL  => '/exercise/subjectSetting',
        ),
        'Course'                                        => array(
            self::TYPE => self::MENU_TYPE_LEFT,
            self::PARENT => 0,
            self::LABEL  => 'course',
            self::TITLE  => '我的课程',
            self::URL  => '/course/scheduleVideo',
        ),
        'Learning'                                      => array(
            self::TYPE => self::MENU_TYPE_LEFT,
            self::PARENT => 0,
            self::LABEL  => 'learning',
            self::TITLE  => '学情查看',
            self::URL  => '/learning/learningStudentList',
        ),
        'Teaching'                                      => array(
            self::TYPE => self::MENU_TYPE_LEFT,
            self::PARENT => 0,
            self::LABEL  => 'teaching',
            self::TITLE  => '教学查看',
            self::URL  => '/teaching/teachingTeacherList',
        ),
        'Provost'                                      => array(
            self::TYPE => self::MENU_TYPE_LEFT,
            self::PARENT => 0,
            self::LABEL  => 'provost',
            self::TITLE  => '教务工作',
            self::URL  => '/provost/provostGroup',
        ),
        'Information'                                      => array(
            self::TYPE => self::MENU_TYPE_LEFT,
            self::PARENT => 0,
            self::LABEL  => 'information',
            self::TITLE  => '信息导入',
            self::URL  => '/information/classImport',
        )
    );

    private static $userMenus = array(
        //超级管理员
        AdminEnum::SUPPER_ADMIN_ROLE   => array(

             #管理员管理
            'ManageAdmin',                   //管理员管理
            'AddAdmin',                      //管理员添加
            'EditAdmin',                     //管理员编辑
            'DeleteAdmin',                   //管理员删除
            'UpDatePwd',                     //管理员修改密码
            'AdminServiceAjax',             //管理员ajax
            #日志管理
            'LogService',                   //日志
            'DeleteLog',                    //日志删除
            'LogServiceAjax',              //日志ajax
            #站内信
            'MessageMail',                   //站内信列表
            'AddMail',                       //站内信发送
            'MailContent',                  //站内信详情页
            #广告位管理
            'AdsList',                      //广告列表
            'AddAds',                       //广告位添加
            'EditAds',                      //广告位编辑
            'DelAds',                       //广告位删除
            'AdsAjax',                      //ajax返回
            #文章管理
            'NewsList',                      //文章列表
            'NewsImport',                    //文章添加
            'NewsEdit',                      //文章编辑
            'NewsDel',                       //文章删除
            'NewsAjax',                      //ajax返回
            'NewsDetails',                   //详细ajax返回
            'IsCarousel',                    //是否启用轮播图
            #文章分类管理
            'NewsCateList',                  //文章分类列表
            'NewsCateImport',                //文章分类添加
            'NewsCateEdit',                  //文章分类编辑
            'NewsCateDel',                   //文章分类删除
            'NewsCateAjax',                  //ajax返回
            #项目管理
            'ItemList',                       //项目列表
            'ItemAdd',                        //项目添加指向
            'ItemImport',                     //项目添加
            'ItemNewAdd',                     //新手标项目指向
            'ItemNewList',                    //新手标项目列表
            'ItemNewEdit',                    //新手标项目编辑
            'IsValid',                         //是否启用体验标
            'CompanyAdd',                      //企业添加指向
            'CompanyList',                     //企业列表
            'CompanyImport',                   //企业添加功能
            'GetEnterprise',                   //根据企业ID查询信息
            'GetItem',                          //根据项目ID查询信息
            'DebtorDetails',                   //项目债务人详情
            'RefundItemPlan',                  //项目还款详情
            'ItemDetail',                      //项目投资明细
            'ItemPlan',                         //投资人计划
            'InvestList',                       //投资记录列表
            #用户中心
            'ManageUser',                      //用户管理
            'AddUser',                         //用户添加
            'EditUser',                        //用户编辑
            'AdminGetUserInfo',               //用户详情
            'UserLocked',                      //用户锁定/解锁
            'UserAwardInfo',                   //用户红包/加息劵信息
            'UserDepositInfo',                 //用户充值
            'UserFund',                        //用户资产
            'UserMessage',                     //用户消息管理
            'AddUserMessage',                  //用户消息添加
            'EditUserMessage',                 //用户消息入库
            'InvitePromotion',                 //邀请推广
            'UserInviteInfo',                  //邀请详情
        ),
        //运营
        AdminEnum::GENERAL_ADMIN_ROLE   => array(
            #广告位管理
            'AdsList',                      //广告列表
            'AddAds',                       //广告位添加
            'EditAds',                      //广告位编辑
            'DelAds',                       //广告位删除
            'AdsAjax',                      //ajax返回
            #文章管理
            'NewsList',                      //文章列表
            'NewsImport',                    //文章添加
            'NewsEdit',                      //文章编辑
            'NewsDel',                       //文章删除
            'NewsAjax',                      //ajax返回
            'NewsDetails',                   //详细ajax返回
            'IsCarousel',                    //是否启用轮播图
            #文章分类管理
            'NewsCateList',                  //文章分类列表
            'NewsCateImport',                //文章分类添加
            'NewsCateEdit',                  //文章分类编辑
            'NewsCateDel',                   //文章分类删除
            'NewsCateAjax',                  //ajax返回
        ),
        //客服
        AdminEnum::EDITOR_ROLE   => array(

            #用户中心
            'ManageUser',                      //用户管理
            'AddUser',                         //用户添加
            'EditUser',                        //用户编辑
            'AdminGetUserInfo',               //用户详情
            'UserLocked',                      //用户锁定/解锁
            'UserAwardInfo',                   //用户红包/加息劵信息
            'UserDepositInfo',                 //用户充值
            'UserFund',                        //用户资产
            'UserMessage',                     //用户消息管理
            'AddUserMessage',                  //用户消息添加
            'EditUserMessage',                 //用户消息入库
            'InvitePromotion',                 //邀请推广
            'InvestList'                        //投资记录
        ),

);

    public static function getUdoMenus()
    {
        return self::$UdoUserMenus;
    }

    public static function getUserMenus($role_id)
    {
        return self::$userMenus[$role_id];
    }

    public static function getLeftMenu($right)
    {

        self::mkNewMenus(self::getUdoMenus());
        $rightMenus = self::getUserMenus($right);

        $aLeftMenus = array();
        foreach ($rightMenus as $menu) {
            if (self::$UdoUserMenus[$menu][self::TYPE] == self::MENU_TYPE_LEFT)
                $aLeftMenus[] = $menu;
        }

        self::$UdoLeftMenu = self::setMenus($aLeftMenus);

        return self::$UdoLeftMenu;
    }

    public static function getLeftLeafMenu()
    {
        $action = self::getCurrentAction();
        self::getRootParent($action);
        $aLeftMenu = self::$UdoLeftMenu[self::$rootParent];
        $aLeafMenu = array();
        if (array_key_exists(self::LEAF, $aLeftMenu)) {
            foreach ($aLeftMenu[self::LEAF] as $leaf) {
                $leaf['label']                   = Lang::get('system.' . $leaf['label']);
                $aLeafMenu[$leaf[self::GROUP]][] = $leaf;
            }
        }

        return $aLeafMenu;
    }

    public static function getRightMenu($right)
    {
        self::mkNewMenus(self::getUdoMenus());
        $rightMenus  = self::getUserMenus($right);
        $aRightMenus = array();
        foreach ($rightMenus as $menu) {
            if (self::$UdoUserMenus[$menu][self::TYPE] == self::MENU_TYPE_RIGHT)
                $aRightMenus[] = $menu;
        }

        return self::setMenus($aRightMenus);
    }

    public static function getTopMenu($right)
    {
        self::mkNewMenus(self::getUdoMenus());
        $rightMenus = self::getUserMenus($right);
        $aTopMenus  = array();
        foreach ($rightMenus as $menu) {
            if (self::$UdoUserMenus[$menu][self::TYPE] == self::MENU_TYPE_TOP)
                $aTopMenus[] = $menu;
        }

        return self::setMenus($aTopMenus);
    }

    public static function getButtonMenu($right)
    {
        self::mkNewMenus(self::getUdoMenus());
        $rightMenus = self::getUserMenus($right);
        $aButMenus  = array();
        foreach ($rightMenus as $menu) {
            if (self::$UdoUserMenus[$menu][self::TYPE] == self::MENU_TYPE_BUTTON)
                $aButMenus[] = $menu;
        }

        return self::setMenus($aButMenus);
    }
}